package com.foodlocker.maintenance;


import org.json.JSONException;
import org.json.JSONObject;

import com.foodlocker.common.CommonFunction;
import com.foodlocker.common.Constant;
import com.foodlocker.machine.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class SynchroDataFragment extends Fragment {

	Button btn_recovery;
	TextView hint;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
	 //return super.onCreateView(inflater, container, savedInstanceState);
		 View view =inflater.inflate(R.layout.fragment_synchrodata, container, false);
		btn_recovery= (Button) view.findViewById(R.id.btn_frg_synchrodata);
		hint= (TextView) view.findViewById(R.id.tvhint__frg_synchrodata);
		btn_recovery.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			
				String params[]= new String[10];
				JSONObject jsonData=new JSONObject();
				try {
					jsonData.put("MID", Constant.MID);
					jsonData.put("Msecret",Constant.Msecret);
				} catch (JSONException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
	             
				params[0]=Constant.PostURLofMachineServlet; //PostCode
				params[1]="8";  
				params[2]=jsonData.toString();
			//	params[7]="1";
			//	params[8]="123456";
				
				new HttpPostTaskforSynchroData().execute(params);
			}
		});
		return view;
	}
	
	 class HttpPostTaskforSynchroData extends android.os.AsyncTask<String,String,String>{

			

			@Override
			protected String doInBackground(String... params) {
				// TODO Auto-generated method stub
				  String result=	CommonFunction.UniversalHttpPost(params);			             
				return result;
			}
			
			@Override
			protected void onPostExecute(String result) {
			
				
			}
	 }
}
